﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace PaladoreQuestItem
{
    class Pali
    {
        public element paliElement;
        public string name;
        public int evolutions, ID;
        public List<Item> drops = new List<Item>();
        public Item drop;
        public List<Quest> quest = new List<Quest>();
        public List<string> areas = new List<string>();

        public Pali(string name)
        {
            this.name = name;
        }
        public Pali(int id, string name, element element, int evolutions, string dropItem, params string[] areas)
        {
            this.ID = id;
            this.name = name;
            this.paliElement = element;
            this.evolutions = evolutions;
            if (dropItem != "")
            {
                //if it exists already, add this pali to main list and make that item this drop
                if (Form1.itemsList.Keys.Contains(dropItem))
                {
                    // code for multiple mobs/items
                    //Form1.itemsList[dropItem].mobs.Add(this);
                    //this.drops.Add(Form1.itemsList[dropItem]);
                    // code for singular mob/item
                    Form1.itemsList[dropItem].mob = this;
                    this.drop = Form1.itemsList[dropItem];
                }
                else //if it doesnt exist, add new one to main list and make that item this drop
                {
                    //multiple mobs/items
                    //Form1.itemsList.Add(dropItem, new Item(dropItem));
                    //this.drops.Add(Form1.itemsList[dropItem]);
                    //single mob/item
                    Form1.itemsList.Add(dropItem, new Item(dropItem));  //make new entry
                    Form1.itemsList[dropItem].mob = this;               //make this pali the mob
                    this.drop = Form1.itemsList[dropItem];              //set this drop from the entry in main list
                }
            }
            //todo: add area stuff ifs and foreaches
        }
        public Pali(string name, element element)
        {
            this.name = name;
            this.paliElement = element;
        }
        public void setPaliAttributes(int id, string name, element element, int evolutions, string dropItem, params string[] areas)
        {
            this.ID = id;
            this.name = name;
            this.paliElement = element;
            this.evolutions = evolutions;
            if (dropItem != "")
            {
                //if it exists already, add the entry to this.list
                if (Form1.itemsList.ContainsKey(dropItem))
                {
                    Form1.itemsList[dropItem].mobs.Add(this);
                    this.drops.Add(Form1.itemsList[dropItem]);
                }
                else    // if it doesnt exist, add it to the main list and add that entry to this.list
                {
                    Form1.itemsList.Add(dropItem, new Item(dropItem));
                    this.drops.Add(Form1.itemsList[dropItem]);
                }
            }
        }
        public Pali findPali(string critter)
        {
            if (this.name == critter) return this;
            else return new Pali(critter);
        }
        public override string ToString()//todo: fill out the tostrings for a pali
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("Pali  #{0:000}:\t{1}\nPali Element:\t{2}\n", ID, name, paliElement);
            if (drop != null) sb.AppendFormat("Drops:\t{0}", drop.ToString(PIQ.Pali));
            //string format1, format2 = "";
            //format1 = string.Format("Pali  #{0:000}:\t{1}\nPali Element:\t{2}\n", ID, name, paliElement);
            string temp = sb.ToString();
            return temp;
        }
        public string ToString(PIQ sender) //todo: if sender==item dostuff; if sender==quest do different
        {
            string format1, format2 = "";
            format1 = string.Format("Pali  #{0:000}:\t{1}\nPali Element:\t{2}\n", ID, name, paliElement);
            if (drop != null) format2 = string.Format("Drops:\t{0}\n", drop.name);

            return format1 + format2;
        }
    }
}
